<?php
class ControllerAccountTransaction extends AccountController {
	public function index() {

      	$this->data['breadcrumbs'][] = array(
        	'text'      => $this->_['text_transaction'],
			'href'      => US('account/transaction'),
        	'separator' => $this->_['text_separator']
      	);

		M('account/transaction');

		$page = $this->request->get('page', 1);

		$this->data['transactions'] = array();

		$this->load->helper('query_filter');
		$qf = new Query_filter(null, false);
		
		$transaction_total = $this->model_account_transaction->getTotalTransactions();
		$results = $this->model_account_transaction->getTransactions($qf);

    	foreach ($results as $result) {
			$this->data['transactions'][] = array(
				'amount'      => currency($result['amount'], C('config_currency')),
				'description' => $result['description'],
				'date_added'  => v5_date_format($result['date_added'])
			);
		}

		$this->data['pagination'] = $this->pagination($transaction_total, $page)->render();

		$this->data['total'] = currency($this->customer->getBalance(), C('config_currency'));

		$this->display('account/transaction.tpl');
	}
}
